﻿using System;
using UnityEngine;

[Serializable]
public class EnemyManager {
    [HideInInspector]
    public Transform spawnPoint;
    //public Color playerColor;
    public GameObject enemyPrefab;

    [HideInInspector]
    public GameObject instance;
    [HideInInspector]
    public bool isSetup;//用于区分:当instance为空，有可能是未setUp，有可能是已destroy

    private TankMove _tankMove;
    private TankShooting _tankShoot;
    private AvoidHorizontal _tankAvoid;
    private TankHealth _tankHealth;

    public void SetUp()
    {
        _tankMove = instance.GetComponent<TankMove>();
        _tankShoot = instance.GetComponent<TankShooting>();
        _tankAvoid = instance.GetComponent<AvoidHorizontal>();
        _tankHealth = instance.GetComponent<TankHealth>();
        isSetup = true;
        /*
        MeshRenderer[] renders = instance.GetComponentsInChildren<MeshRenderer>();
        for(int i=0; i<renders.Length; i++)
        {
            renders[i].material.color = playerColor;
        }
        */
    }
}
